package file;

import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.Field;

public class Test2 {
    public static void main(String[] args) {
        File file = new File(".");
        FileFilter filter = new FileFilter() {
            public boolean accept(File pathname) {
                String name = pathname.getName();
                System.out.println(name);
                return name.startsWith("test");
            }
        };
        File [] sub = file.listFiles(filter);
        System.out.println("符合条件的有"+sub.length+"个");
        for (File fi : sub) {
            System.out.println(fi.getName());
        }
        System.out.println();
        System.out.println();
        File [] subs = file.listFiles(f->f.getName().contains("t"));
        for (File a: subs) {
            System.out.println(a.getName());
        }
    }
}
